//
//  UITextView+Helper.m
//  ruying
//
//  Created by yqh on 2019/3/16.
//  Copyright © 2019年 林伟钦. All rights reserved.
//

#import "UITextView+Helper.h"

@implementation UITextView (Helper)

- (void)setPlaceHolder:(NSString *)placeholdStr
{
    [self setPlaceHolder:placeholdStr placeholdColor:[UIColor lightGrayColor]];
}

- (void)setPlaceHolder:(NSString *)placeholdStr placeholdColor:(UIColor *)placeholdColor
{
    
    UILabel *lbl = [self valueForKey:@"_placeholderLabel"];
    if (lbl) {
        [lbl removeFromSuperview];
        lbl = nil;
    }
    
    UILabel *label = [[UILabel alloc] init];
    label.text = placeholdStr;
    label.numberOfLines = 0;
    label.textColor = placeholdColor;
    label.font = self.font;
    [label sizeToFit];
    [self addSubview:label];
    
    [self setValue:label forKey:@"_placeholderLabel"];
}
@end
